package interpreter.operation;

/**
 * @author Roderland
 * @since 1.0
 */
public enum Opcode {
    MOV_REG_REG("mov_reg_reg"),
    MOV_IMM_REG("mov_imm_reg"),
    MOV_REG_MM("mov_reg_mm"),
    MOV_MM_REG("mov_mm_reg"),
    ADD_REG_REG("add_reg_reg"),
    PUSH("push"),
    POP("pop"),
    CALL("call"),
    RET("ret");

    public static Opcode getOpcode(String name) {
        switch (name) {
            case "MOV_REG_REG": return MOV_REG_REG;
            case "MOV_IMM_REG": return MOV_IMM_REG;
            case "MOV_REG_MM": return MOV_REG_MM;
            case "MOV_MM_REG": return MOV_MM_REG;
            case "ADD_REG_REG": return ADD_REG_REG;
            case "PUSH": return PUSH;
            case "POP": return POP;
            case "CALL": return CALL;
            case "RET": return RET;
        }
        return null;
    }

    private final String name;

    Opcode(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
